#ifndef READERSQL_H
#define READERSQL_H

#include <QObject>
#include <QMessageBox>
#include <QCoreApplication>
#include <QSqlQuery>
#include <QtDebug>
#include <QSqlError>
#include <QsqlDatabase>

struct ReaderInfo
{QString ID;
 QString password;
 QString name;
 quint8 age;
 quint8 grade;
 QString major;
 int studentid;
 QString phone;
 QString email;
 QString book_overtime;
 QString book_borrowed;


 ReaderInfo(QString id,QString pa,QString na,quint8 ag,quint8 gra,QString ma,int sid,QString ph,QString em,QString bo,QString bb)
 {ID = id;
  password = pa;
  name = na;
  age = ag;
  grade = gra;
  major = ma;
  studentid = sid;
  phone = ph;
  email = em;
  book_borrowed=bb;
  book_overtime=bo;
  }

};
class Readersql : public QObject
{
    Q_OBJECT
public:
    explicit Readersql(QObject *parent = nullptr);
    void init();
    //查询第几页读者数据
    QList<ReaderInfo> getPageStu(quint32 page,quint32 uiCnt);
    //增加读者
    bool addStu(ReaderInfo);
    //注销读者
    bool delStu();
    //修改读者信息
    void UptateReaderInfo(ReaderInfo info);
    //查询所有读者
    QList<ReaderInfo> GetAll();
    //查询读者ID是否存在
    bool Exist(int ID);
    QString Password(QString user);
    QSqlDatabase m_db;
    int fn(QChar c);
    int char_to_int(QString s);
private:

signals:

};



#endif // READERSQL_H
